import java.util.Stack;

/**
 * @author wtcode
 * @date 2021/3/11 - 9:45
 *
 * 判断是否为对称二叉树
 */
public class Offer28 {
    public boolean isSymmetric(TreeNode root) {
        if(root == null) return true;
        return check(root.left,root.right);
    }
    public boolean check(TreeNode left , TreeNode right){
        if(left == null && right == null) return true;
        if(left == null || left ==null) return false;
        return left.val == right.val && check(left.left,right.right) && check(left.right,right.left);
    }
}
class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;

    TreeNode(int x) {
        val = x;
    }
}